package learn.contorlller;

import learn.bean.Person;
import org.springframework.core.io.FileSystemResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author yxc
 * @Date 2022/1/5
 */
@RestController
public class ResponseTestController {

    /**
     * 1、浏览器发请求直接返回xml  application/xml  jacksonXmlConverter
     * 2、ajax请求 返回json   application/json  jacksonJsonConverter
     * 3、app请求  返回自定义数据
     * <p>
     * 步骤：
     * 1、添加自定义的MessageConverter进系统底层
     * 2、系统底层就会统计出所有MessageConverter能操作那些类型
     * 3、客户端内容协商
     *
     * @return
     */
    @ResponseBody
    @GetMapping("/test/person")
    public Person getPerson() {
        Person person = new Person();
        person.setAge(18);
        person.setUsername("张三");
        return person;
    }

    @ResponseBody // --RequestResponseBodyMehtodProcessor --> messageConverter
    @GetMapping("/hell")
    public FileSystemResource file() {

        return null;
    }
}
